
public class OpenFile {

   public static Translator getTranslator(String fileType) {
      if (fileType.equals("doc")) {
         return new WordTranslator();
      } else if (fileType.equals("html")) {
         return new HTMLTranslator();
      } else if (fileType.equals("txt")) {
         return new PlainTranslator();
      } else if (fileType.equals("xml")) {
         return new XMLTranslator();
      } else {
         return new DefaultTranslator();
      }
   }

   public static void main(String[] args) {
      for (int i = 0; i < 100; i++) {
               System.out.println(getTranslator("txt"));
      }

   }

}

